﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Linq.Expressions;
//using System.Text;
//using System.Threading.Tasks;

//namespace Sop.LinqProvider
//{
//    internal class QueryableStore<TKey, TValue> : IOrderedQueryable<KeyValuePair<TKey, TValue>>
//    {

//        #region Constructors
//        /// <summary> 
//        /// This constructor is called by the client to create the data source. 
//        /// </summary> 
//        public QueryableStore()
//        {
//            Provider = new QueryableStoreProvider();
//            Expression = Expression.Constant(this);
//        }

//        /// <summary> 
//        /// This constructor is called by Provider.CreateQuery(). 
//        /// </summary> 
//        /// <param name="expression"></param>
//        public QueryableStore(QueryableStoreProvider provider, Expression expression)
//        {
//            if (provider == null)
//            {
//                throw new ArgumentNullException("provider");
//            }

//            if (expression == null)
//            {
//                throw new ArgumentNullException("expression");
//            }

//            if (!typeof(IQueryable<KeyValuePair<TKey, TValue>>).IsAssignableFrom(expression.Type))
//            {
//                throw new ArgumentOutOfRangeException("expression");
//            }

//            Provider = provider;
//            Expression = expression;
//        }
//        #endregion

//        #region Properties

//        public IQueryProvider Provider { get; private set; }
//        public Expression Expression { get; private set; }

//        public Type ElementType
//        {
//            get { return typeof(KeyValuePair<TKey, TValue>); }
//        }

//        #endregion

//        #region Enumerators
//        public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
//        {
//            return (Provider.Execute<IEnumerable<KeyValuePair<TKey, TValue>>>(Expression)).GetEnumerator();
//        }

//        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
//        {
//            return (Provider.Execute<System.Collections.IEnumerable>(Expression)).GetEnumerator();
//        }
//        #endregion
//    }
//}
